const axios = require('axios');
const logger = (message) => {
    const now = new Date();
    const chinaTime = new Date(now.getTime() + 8 * 60 * 60 * 1000);
    const chinaTimeStr = chinaTime.toISOString().replace('Z', '+08:00');
    console.log(`[${chinaTimeStr}] ${message}`);
};
const config = require('../../config');

async function sendDingTalk(content) {
    try {
        await axios.post(config.DINGTALK_WEBHOOK, {
            msgtype: 'text',
            text: { content }
        });
        return true;
    } catch (error) {
        logger(`[ERROR]:钉钉通知发送失败: ${error.message}`);
        return false;
    }
}

module.exports = { sendDingTalk };